#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Singleton class unit test
"""

import unittest
from singleton import Singleton


class A(Singleton):
    name = 'Child A'

class B(Singleton):
    name = 'Child B --> A'
    
class C(object):
    name = 'C'

class SingletonTest(unittest.TestCase):
    
    def test_instance(self):
        a = A()
        self.assertEqual(id(a), id(A.get_instance()))
        self.assertEqual(id(a), id(A()))
        
        b = B()
        self.assertEqual(id(b), id(B.get_instance()))
        self.assertEqual(id(b), id(B()))
        
        c = C()
        self.assertNotEqual(id(c), id(C()))
        
        s = Singleton()
        self.assertEqual(id(s), id(Singleton.get_instance()))
        self.assertEqual(id(s), id(Singleton()))
        
        self.assertNotEqual(id(a), id(s))
        self.assertNotEqual(id(b), id(s))
        self.assertNotEqual(id(a), id(b))
        
if __name__ == '__main__':
    unittest.main()